//
//  ColorMacros.swift
//  ZuoGJByOwnerSide
//
//  Created by lantaiyuan on 2017/8/4.
//  Copyright © 2017年 lantaiyuan. All rights reserved.
//

import Foundation
import UIKit
extension UIColor {
    
    /// 用十六进制颜色创建UIColor
    ///
    /// - Parameter hexColor: 十六进制颜色 (0F0F0F)
    convenience init(withHexString: String) {
        
        // 存储转换后的数值
        var red:UInt32 = 0, green:UInt32 = 0, blue:UInt32 = 0
        
        // 分别转换进行转换
        Scanner(string: withHexString[0..<2]).scanHexInt32(&red)
        
        Scanner(string: withHexString[2..<4]).scanHexInt32(&green)
        
        Scanner(string: withHexString[4..<6]).scanHexInt32(&blue)
        
        self.init(red: CGFloat(red)/255.0, green: CGFloat(green)/255.0, blue: CGFloat(blue)/255.0, alpha: 1.0)
    }
}
extension String {
    
    /// String使用下标截取字符串
    /// 例: "示例字符串"[0..<2] 结果是 "示例"
    subscript (r: Range<Int>) -> String {
        get {
            let startIndex = self.index(self.startIndex, offsetBy: r.lowerBound)
            let endIndex = self.index(self.startIndex, offsetBy: r.upperBound)
            
            return self[startIndex..<endIndex]
        }
    }
}
/**获取RGB颜色*/
public func RGBA(r:CGFloat,g:CGFloat,b:CGFloat,a:CGFloat) -> UIColor {
    return UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: a)
}
public func RGB(r:CGFloat,g:CGFloat,b:CGFloat) -> UIColor {
    return RGBA(r: r, g: g, b: b, a: 1.0)
}
//返回无颜色
public func ClearColor() ->UIColor {
  return UIColor.clear
}
public func RANDOM_COLOR() ->UIColor {

 return UIColor.init(colorLiteralRed: Float(arc4random_uniform(255) / 255), green: Float(arc4random_uniform(255) / 255), blue: Float(arc4random_uniform(255) / 255), alpha: 1)
}

/*默认颜色*/
func RGBColor(r :CGFloat ,g:CGFloat,b:CGFloat) ->UIColor{
    return UIColor.init(colorLiteralRed: Float(r / 255.0), green:Float(g / 255.0) , blue:Float (b / 255.0), alpha: 1)
}
func RGBCOLOR_HEX(h:Int) ->UIColor {
    return RGBColor(r: CGFloat(((h)>>16) & 0xFF), g:   CGFloat(((h)>>8) & 0xFF), b:  CGFloat((h) & 0xFF))
}


// 导航栏颜色
public let NAV_BAR_COLOR =  UIColor.init(withHexString: "#3b3a3f")

// 导航栏标题颜色
public let NAV_TITLE_COLOR = UIColor.white

// 标签栏颜色（高亮）
public let TABBAR_COLOR_HIGHLIGHTED = UIColor.init(withHexString: "#00a73c")

// 标题颜色
public let TITLE_COLOR = UIColor.init(withHexString: "#333333")

// 副标题颜色
public let SUB_TITLE_COLOR = UIColor.init(withHexString: "#666666")
// 灰色
public let GRAY_COLOR =  UIColor.init(withHexString: "#999999")

// 背景色
public let CONTENT_BG_COLOR  = UIColor.init(withHexString: "#f5f5f5")

// 分隔线颜色
public let SEPARATE_LINE_COLOR = UIColor.init(withHexString: "#dddddd")

// 边框线颜色
public let BORDER_COLOR = UIColor.init(withHexString: "#faaf19")

// 边框线颜色(灰色)
public let BORDER_COLOR_GRAY = UIColor.init(withHexString: "#dddddd")
// 占位文字颜色
public let PLACEHOLDER_COLOR = UIColor.init(withHexString: "#bbbbbb")
// 边框颜色
public let WORK_LINE_COLOR = UIColor.init(withHexString: "#bbbbbb")
// 错误提示文字颜色
public let ERROR_COLOR = UIColor.init(withHexString: "#fa4535")

// 成功文字颜色
public let SUCCESS_COLOR = UIColor.init(withHexString: "#5298ff")

// 支付颜色
public let PAY_COLOR = UIColor.init(withHexString: "#faaf19")

// 按住时的颜色
public let PRESS_COLOR = UIColor.init(withHexString: "#1d7f38")

// 绿色
public let GREEN_COLOR = UIColor.init(withHexString: "#2ab650")
// 红色
public let RED_COLOR = UIColor.init(withHexString: "#fa4535")
// 橘色
public let ORANGE_COLOR = UIColor.init(withHexString: "#fa483a")

// 白色
public let WHITE_COLOR = UIColor.init(withHexString: "#ffffff")
//深灰
public let DEEP_GRAY_COLOR = UIColor.init(withHexString:"#7a7a7a")
// 轮播条颜色
public let pageDot_Color = UIColor.init(withHexString:"#229240")

// 地图线条颜色
public let MAP_LINE_COLOR = UIColor.init(withHexString:"#5298ff")

//日历背景色
public let CALENDAR_BG_COLOR = UIColor.init(withHexString:"#dddddd")
//日历文字色
public let CALENDAR_SUBTITLE_COLOR = UIColor.init(withHexString:"#AAAAAA")
//评价页面按钮
public let Emergency_COLOR = UIColor.init(withHexString:"#bbbbbb")
//橘色
public let ORANGEe_COLOR = UIColor.init(withHexString:"#fa9338")
//橘红色
public let RED_ORANGE_COLOR = UIColor.init(withHexString:"#fb6a67")
//紫色
public let PUPO_COLOR = UIColor.init(withHexString:"#d989f7")
//蓝色
public let BLUE_COLOR = UIColor.init(withHexString:"#5da7fa")
//深蓝色
public let DipBlue_COLOR = UIColor.init(withHexString:"#00ccff")
//紫色
public let purple_color = UIColor.init(withHexString:"#5cccfa")
//发现定制公交颜色
public let discover_purple_color = UIColor.init(withHexString:"#ff9a0a")
//拼车订单待支付
public let discover_red_color = UIColor.init(withHexString:"#fb5042")
public let LoginTextfieldColor = UIColor.init(withHexString:"#7ecc8f")
public let setPayWordColor = UIColor.init(withHexString:"#b4b4b4")
